const router = require('express').Router()
const _ = require('lodash/fp')
const U = require('../../utils')
const shops = require('../../controllers/user-end/shops')

function abort_not_login(req,res,next){
  if(_.has(['session','user','user'],req)){
    console.log('abort_not_login: user is ' + req.session.user.user)
    next()
  }else{
    res.json(U.Err('请先登录'))
  }
}

router.route('/')
  // .all(abort_not_login)
  .get((req,res) => {
    res.json(U.Ok(shops.all_shops()))
  })

module.exports = router